#include <myheader_c_plus.h>
using std::endl;
using std::cout;
class GrandPa{
public:
    GrandPa(){cout << "GrandPa()" << endl;}

    ~GrandPa(){cout << "~GrandPa()" << endl;}

    virtual void func1(){cout << "Grand func1" << endl;}

    virtual void func2(){cout << "Grand func2" << endl;}

};

class Parent : public GrandPa{
public:
    Parent(){
        cout << "Parent()" << endl;
        func1();
    }
    ~Parent(){
        func2();
        cout << "~Parent()" << endl;
    }


};


class Child : public Parent{
public:
    Child(){
        cout << "Child()" << endl;
    }

    ~Child(){
        cout << "~Child()" << endl;
    }

    virtual void func1() override{
        cout << "child func1" << endl;
    }

    virtual void func2() override{
        cout << "child func2" << endl;
    }
};
int main(int argc, char *argv[])
{
    Child c;
    GrandPa * pg = &c;
    pg->func1();
    pg->func2();
    return 0;
}

